import java.util.ArrayList;


public class RandomValue {
	//private  ArrayList<Integer> candidates;
	
	RandomValue()
	{
		
	}
	
	/*
	 * randomly return an integer value from 0 to maximum
	 */
	public static int getRandomValue(int maximum)
	{
		int candidate;
		if (0 >= maximum)
		{
			System.out.print("Error, ArrayList is empty!\n");
			return -1;
		}
		
		candidate = (int) (Math.random() * maximum);
		return candidate;
	}
	
	/*
	 * randomly return a item from an arraylist
	 */
	public static int getRandomItem(ArrayList<Integer> candidates)
	{
		int candidate;
		if (0 == candidates.size())
		{
			System.out.print("Error, ArrayList is empty!\n");
			return -1;
		}
		int cardinanlity = candidates.size();
		candidate = (int) (Math.random() * cardinanlity);
		return candidates.get(candidate);
	}

}
